package org.example.account.controller;

import org.example.account.service.AccountService;
import org.example.entity.Account;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RequestMapping("/account")
@RestController
public class AccountController {

    @Autowired
    private AccountService accountService;

    @GetMapping("/{id}")
    public Account queryById(@PathVariable("id") Long id) {
        return accountService.findById(id);
    }

    @GetMapping("/reduceMoney")
    public String reduceAccountMoney(@RequestParam("id") Long id, @RequestParam("money") Double money) {
        accountService.reduceAccountMoney(id, money);
        return "ok";
    }
}
